# -*- coding UTF-8 -*-
import unittest

from game_config import GameConfig
from presenter_mock import PresenterMock
from model import gamestate


class GameConfigTest(unittest.TestCase):
    def setUp(self):
        settings = gamestate.Settings(20, 10)
        self.gamestate = gamestate.GameState(None, None, None,
                                             gamestate.Phase.GAME_CONFIG,
                                             None, None, settings)
        self.presenter = PresenterMock(gamestate.Phase.START_GAME)

    def test_button_pressed(self):
        widget = GameConfig(self.gamestate, self.presenter)
        self.assertEquals(self.presenter.is_phase_changed, False)
        self.assertEquals(self.gamestate.settings.time_per_round_sec, 10)
        self.assertEquals(self.gamestate.settings.words_number, 20)
        widget.PROPS['time'].change_property(5, widget.PROPS['time'].inp)
        widget.PROPS['words'].change_property(-1, widget.PROPS['words'].inp)
        widget.next_view()
        self.assertEquals(self.presenter.is_phase_changed, True)
        self.assertEquals(self.gamestate.settings.time_per_round_sec, 15)
        self.assertEquals(self.gamestate.settings.words_number, 19)


if __name__ == '__main__':
    unittest.main()
